﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TicTacToe
{
    public partial class Default : System.Web.UI.Page
    {
        protected void gameBoard_GameComplete(object sender, BoardControl.BoardEventArgs e)
        {
            string winnerText = string.Empty;
            switch (e.Winner)
            {
                case BoardPlayer.Player:
                    winnerText = "You have won!";
                    break;
                case BoardPlayer.Computer:
                    winnerText = "The computer has won!";
                    break;
                case BoardPlayer.NoPlayer:
                    winnerText = "It's a tie!";
                    break;
            }

            lblWinner.Text = winnerText;
            btnPlayAgain.Enabled = true;
        }

        protected void btnPlayAgain_Click(object sender, EventArgs e)
        {
            gameBoard.Reset();
        }
    }
}